cmake_minimum_required(VERSION 3.22.0)
project(demo)

find_package(Protobuf REQUIRED)

message(REQUIRED)
message(Protobuf)
message(${PROTOBUF_INCLUDE_DIRS})

include_directories(${PROTOBUF_INCLUDE_DIRS})

set(PROTO_FILES YourProtoFile.proto)

# protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})

execute_process(COMMAND protoc --cpp_out=. msg.proto)

add_compile_options(-lprotobuf)

add_executable(MyApp main.cpp ${PROTO_SRCS} ${PROTO_HDRS})

target_link_libraries(MyApp ${PROTOBUF_LIBRARIES})